<?php
namespace Admin\Controller;
use Think\Controller;
class PublicController extends Controller
{
    //登录用户
    public function login($username = null, $password = null, $verify = null)
    {
        if(IS_POST)
        {
            $model = D("AdminUser");
            $uid = $model->login($username, $password);
            if(0 < $uid){ //UC登录成功
                //TODO:跳转到登录前页面
                $this->success('登录成功！', U('Index/index'));
            } else {
                $this->error($model->getError());
            }        
        } else {
            $this->display();
        }
    }
    
    //注销用户
    public function logout()
    {
        session('uid', null);
        $this->redirect("Public/login");
    }
    
    //获取栏目列表
    public function nav() 
    {
        $data = array(
            array(
                "title" => "网站信息",
            	"icon"  => "fa-cubes",
            	"href"  => U('Info/index'),
	            "spread"=> false,
            ),
            array(
                "title" => "导航管理",
                'icon'  => "fa-cubes",
                "spread"=> false,
                "children" => array(
                    array(
                        "title"   => "导航列表",
                        "icon"    => "&#xe63c;",
                        "href"    => U('Nav/index'),
                    ),
                ),
            ),
            array(
                "title" => "栏目管理",
                'icon'  => "fa-cubes",
                "spread"=> false,
                "children" => array(
                    array(
                        "title"   => "栏目列表",
                        "icon"    => "&#xe63c;",
                        "href"    => U('Column/index'),
                    ),
                ),
            ),
            array(
                "title" => "数据管理",
                'icon'  => "fa-cubes",
                "spread"=> false,
                "children" => array(
                    array(
                        "title"   => "文章列表",
                        "icon"    => "&#xe63c;",
                        "href"    => U('Article/index'),
                    ),
                    array(
                        "title"   => "轮播图列表",
                        "icon"    => "&#xe63c;",
                        "href"    => U('Carousel/index'),
                    ),
                ),
            ),
            array(
                "title" => "会员管理",
                'icon'  => "fa-cubes",
                "spread"=> false,
                "children" => array(
                    array(
                        "title"   => "会员列表",
                        "icon"    => "&#xe63c;",
                        "href"    => U('Member/index'),
                    ),
                ),
            ),
    	);
        $this->ajaxReturn($data, 'json');
    }
}